home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / vsfd1016 / data1.cab / Sample_-_Linked_List / frmMain.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-08-03  |  3.7 KB  |  122 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMain 
  3.    Caption         =   "Demo VSFlexData - Linked List"
  4.    ClientHeight    =   1350
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   1350
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.Label Label1 
  13.       Caption         =   "Please follow along documented code and look at the immediate pane for results."
  14.       Height          =   855
  15.       Left            =   360
  16.       TabIndex        =   0
  17.       Top             =   240
  18.       Width           =   3495
  19.    End
  20. Attribute VB_Name = "frmMain"
  21. Attribute VB_GlobalNameSpace = False
  22. Attribute VB_Creatable = False
  23. Attribute VB_PredeclaredId = True
  24. Attribute VB_Exposed = False
  25. ' Demonsration of VSFlexData object
  26. ' Copyright
  27.  1998, VocalSoft Communications
  28. ' All rights reserved.
  29. Option Explicit
  30. ' The purpose of this project is to demostrate how to
  31. ' create a doubly linked list with a few lines of code.
  32. ' The created list is flexible enough to store any
  33. ' kind of data.
  34. ' The actual code for the linked list is in List.BAS.
  35. Private Sub Form_Load()
  36.     Dim x As VSFlexData: Set x = New VSFlexData
  37.     ' Initialize the list
  38.     InitList
  39.     ' Demonstrate the list with one kind of data:
  40.     ' This particular data consists of heights and
  41.     ' weights.
  42.     DemoMeasures
  43.     ' Initialize the list again
  44.     InitList
  45.     ' Now use the same code to demonstrate how we can
  46.     ' use a different kind of data with the same list
  47.     ' code.  This particular data consists of Names,
  48.     ' Addresses, and Phone Numbers.
  49.     DemoPhonebook
  50. End Sub
  51. Private Sub InitList()
  52.     ' In case it's already set
  53.     Set g_vsfList = Nothing
  54.     ' Instantiate the object
  55.     Set g_vsfList = New VSFlexData
  56.     ' Setup the object of dynamic array type
  57.     g_vsfList.SetArray
  58. End Sub
  59. Private Sub DemoMeasures()
  60.     ' Demonstrates how the list code is used to store and
  61.     ' maintain heights and weights
  62.     ' Create a new map
  63.     Dim vsfData As VSFlexData
  64.     Set vsfData = New VSFlexData
  65.     vsfData.SetMap
  66.     ' Setup the map with height and
  67.     ' weight
  68.     vsfData!Height = 4.1
  69.     vsfData!Weight = 55
  70.     ' Add map to the list
  71.     InsertNode vsfData
  72.     '... REPEAT...
  73.     vsfData!Height = 5.3
  74.     vsfData!Weight = 75
  75.     InsertNode vsfData
  76.     '... REPEAT...
  77.     vsfData!Height = 6.2
  78.     vsfData!Weight = 105
  79.     InsertNode vsfData
  80.     ' Traverse the list and
  81.     ' print data in the debug window or
  82.     ' immediate pane
  83.     TraversePrint
  84.     Debug.Print
  85. End Sub
  86. Private Sub DemoPhonebook()
  87.     ' Demonstrates how the same list code is used to
  88.     ' store and maintain a different kind
  89.     ' of data: phonebook entries
  90.     ' Create a new map
  91.     Dim vsfData As VSFlexData
  92.     Set vsfData = New VSFlexData
  93.     vsfData.SetMap
  94.     ' Setup the map with phonebook
  95.     ' entries
  96.     vsfData!Name = "Bill Gates"
  97.     vsfData!Address = "10 Microsoft Drive"
  98.     vsfData!Phone = 9005551212#
  99.     ' Add map to the list
  100.     InsertNode vsfData
  101.     ' ...REPEAT...
  102.     vsfData!Name = "Ross Perot"
  103.     vsfData!Address = "15 Texas Ave."
  104.     vsfData!Phone = 8005551212#
  105.     InsertNode vsfData
  106.     ' ...REPEAT...
  107.     vsfData!Name = "Tom Cruise"
  108.     vsfData!Address = "1 Hollywood Circle"
  109.     vsfData!Phone = 8885551212#
  110.     InsertNode vsfData
  111.     ' Traverse the list and
  112.     ' print data in the debug window or
  113.     ' immediate pane
  114.     TraversePrint
  115.     Debug.Print
  116. End Sub
  117. Private Sub Form_Unload(Cancel As Integer)
  118.     ' Clear the object
  119.     g_vsfList.RemoveAll
  120.     Set g_vsfList = Nothing
  121. End Sub
  122.